package com.example.lcode.dp;

public class Question300 {


    public int lengthOfLIS(int[] nums) {
        // 代表以 i 为结尾的 最长长度
        int []dp = new int[nums.length];
        int res  = 0;
        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
            for (int j = 0; j < i ; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
            res = Math.max(res, dp[i]);
        }
        return res;
    }

    public static void main(String[] args) {
        Question300 question300 = new Question300();
        int []arr = {10,9,2,5,3,7,101,18};
        int i = question300.lengthOfLIS(arr);
        System.out.println(i);
    }

}
